import QRequest from '@/service/index';
import { WorkingHoursParams, WorkingHoursResponse, WorkingHours } from './model/type';
import { generateNameToLevel } from '@/config/constant';

/**
 * @description: 工作时段列表
 * @param {WorkingHoursParams} params
 * @return {*}
 */
export const doGetWorkingPeriodList = (params: WorkingHoursParams) => {
    return QRequest.get<WorkingHoursResponse>(`/workingPeriod`, {
        params,
        headers: {
            loadingTarget: `#${generateNameToLevel('2')}`
        }
    });
};

/**
 * @description: 新增工作时段
 * @param {WorkingHoursParams} params
 * @return {*}
 */
export const doAddPeriodList = (data: Partial<Omit<WorkingHours, 'unEditable'>>[]) => {
    return QRequest.post(`/workingPeriod/save`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @description: 编辑工作时段
 * @param {WorkingHoursParams} params
 * @return {*}
 */
export const doUpdatePeriodList = (data: Partial<Omit<WorkingHours, 'unEditable'>>[]) => {
    return QRequest.put(`/workingPeriod/update`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @description: 删除工作时段
 * @param {WorkingHoursParams} params
 * @return {*}
 */
export const doDelPeriodList = (data: number[]) => {
    return QRequest.delete(`/workingPeriod/delete`, {
        data,
        headers: {
            hideLoading: 1
        }
    });
};
